﻿Imports System.Data.OracleClient
Imports System.Xml

Namespace persistent


    Public Class ChangeSIMpersistence
        Private Shared ConnStr As String = GlobalVar.OraConnStr

        Private Shared dbPackageName As String = "EU_BILL.ChangeSIM."

        Public Shared Function CheckMernisStatus(ByVal tcID As String, ByRef name As String, ByRef surname As String) As Object

            Try

                Dim requestBody As String = String.Format("<?xml version='1.0' encoding='UTF-8'?> " & _
                                                vbNewLine & "<IWIS_IN_DATA_UNIT> " & _
                                                vbNewLine & "<IWIS_IN_HEADER version='1.0'> " & _
                                                vbNewLine & "<SYSTEM>OTONOM</SYSTEM> " & _
                                                vbNewLine & "<SERVICE>MERNIS_GET_CUSTOMER_BY_ID</SERVICE> " & _
                                                vbNewLine & "</IWIS_IN_HEADER> " & _
                                                vbNewLine & "<IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "<TYPE>1</TYPE> " & _
                                                vbNewLine & "<NATIONALID>{0}</NATIONALID> " & _
                                                vbNewLine & "</IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "</IWIS_IN_DATA_UNIT>", _
                                                tcID)










                Dim serviceAddress As Object = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                'Dim serviceAddress As String = "http://10.4.42.42/WEB/IWIS"
                'Dim serviceAddress As String = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                Dim data() As Byte = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("windows-1254"), System.Text.Encoding.GetEncoding("iso-8859-9"), System.Text.Encoding.GetEncoding("windows-1254").GetBytes(requestBody))
                Dim StringServiceAddress As String = Convert.ToString(serviceAddress)
                Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(serviceAddress)

                request.Method = "POST"
                request.ContentType = "content=""text/xml;charset=iso-8859-9"""
                request.ContentLength = data.Length
                Dim streamWriter As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.GetEncoding("iso-8859-9"))

                streamWriter.Write(System.Text.Encoding.GetEncoding("iso-8859-9").GetString(data))
                streamWriter.Close()


                Dim response As System.IO.Stream = request.GetResponse().GetResponseStream()
                Dim streamReader As New IO.StreamReader(response, System.Text.Encoding.GetEncoding("iso-8859-9"))
                Dim responseContent As String = streamReader.ReadToEnd()
                Dim upperedResponseContent As String = responseContent.ToUpper()

                Dim resultCode As String = responseContent.Substring _
                ( _
                    upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length, _
                    upperedResponseContent.IndexOf("</IWIS_RETURN_CODE>") - (upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length) _
                )

                Dim _name As String = name, _surname As String = surname
                Dim resultcd As Integer = Convert.ToInt32(resultCode)
                If resultcd <> 0 Then
                    name = responseContent.Substring(upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length))
                    name = responseContent.Substring _
                   ( _
                      upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, _
                     upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length) _
                   )
                    surname = responseContent.Substring(upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length))
                    surname = responseContent.Substring _
                   ( _
                      upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, _
                     upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length) _
                   )



                    ' gender = responseContent.Substring(upperedResponseContent.IndexOf("<GENDER>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length, _
                    '  upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length) _
                    ')

                    ' fatherName = responseContent.Substring(upperedResponseContent.IndexOf("<FATHERNAME>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length) _
                    ')

                    ' motherName = responseContent.Substring(upperedResponseContent.IndexOf("<MOTHERNAME>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length) _
                    ')


                    ' birthDay = responseContent.Substring(upperedResponseContent.IndexOf("<birthDay>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, _
                    '  upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length) _
                    ')

                    ' birthMonth = responseContent.Substring(upperedResponseContent.IndexOf("<birthMonth>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, _
                    '  upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length) _
                    ')

                    ' birthYear = responseContent.Substring(upperedResponseContent.IndexOf("<birthYear>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, _
                    '  upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length) _
                    ')
                    ' cityName = responseContent.Substring(upperedResponseContent.IndexOf("<cityName>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, _
                    '  upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length) _
                    ')

                    ' countyName = responseContent.Substring(upperedResponseContent.IndexOf("<countyName>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, _
                    '  upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length) _
                    ')

                    ' anneKizlikSoyad = responseContent.Substring(upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length, _
                    '  upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length) _
                    ')




                End If

                If (Not name Is Nothing) AndAlso name.Trim().ToLower() = "null" Then
                    If Not _name Is Nothing Then
                        name = _name
                    End If

                    If Not _surname Is Nothing Then
                        name = _surname
                    End If

                    resultCode = "-1"
                End If

                If resultCode <> "0" Then
                    resultCode = "-1"
                End If

                Return resultCode
            Catch ex As Exception
                Return -1
            End Try

        End Function



        Public Shared Function CheckMernisStatus2(ByVal tcID As String, ByRef name As String, ByRef surname As String, ByRef gender As String, ByRef fatherName As String, ByRef birthDay As String, ByRef birthMonth As String, ByRef birthYear As String, ByRef cityName As String, ByRef countyName As String, ByRef anneKizlikSoyad As String, ByRef birthPlace As String) As Object

            Try

                Dim requestBody As String = String.Format("<?xml version='1.0' encoding='UTF-8'?> " & _
                                                vbNewLine & "<IWIS_IN_DATA_UNIT> " & _
                                                vbNewLine & "<IWIS_IN_HEADER version='1.0'> " & _
                                                vbNewLine & "<SYSTEM>OTONOM</SYSTEM> " & _
                                                vbNewLine & "<SERVICE>MERNIS_GET_CUSTOMER_BY_ID</SERVICE> " & _
                                                vbNewLine & "</IWIS_IN_HEADER> " & _
                                                vbNewLine & "<IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "<TYPE>1</TYPE> " & _
                                                vbNewLine & "<NATIONALID>{0}</NATIONALID> " & _
                                                vbNewLine & "</IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "</IWIS_IN_DATA_UNIT>", _
                                                tcID)










                'Dim serviceAddress As String = "http://10.4.42.42/WEB/IWIS"
                Dim serviceAddress As Object = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                'Dim serviceAddress As String = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                Dim data() As Byte = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("windows-1254"), System.Text.Encoding.GetEncoding("iso-8859-9"), System.Text.Encoding.GetEncoding("windows-1254").GetBytes(requestBody))
                Dim StringServiceAddress As String = Convert.ToString(serviceAddress)
                Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(serviceAddress)

                request.Method = "POST"
                request.ContentType = "content=""text/xml;charset=iso-8859-9"""
                request.ContentLength = data.Length
                Dim streamWriter As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.GetEncoding("iso-8859-9"))

                streamWriter.Write(System.Text.Encoding.GetEncoding("iso-8859-9").GetString(data))
                streamWriter.Close()


                Dim response As System.IO.Stream = request.GetResponse().GetResponseStream()
                Dim streamReader As New IO.StreamReader(response, System.Text.Encoding.GetEncoding("iso-8859-9"))
                Dim responseContent As String = streamReader.ReadToEnd()
                Dim upperedResponseContent As String = responseContent

                Dim resultCode As String = responseContent.Substring _
                ( _
                    upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length, _
                    upperedResponseContent.IndexOf("</IWIS_RETURN_CODE>") - (upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length) _
                )

                Dim _name As String = name, _surname As String = surname
                Dim resultcd As Integer = Convert.ToInt32(resultCode)
                name = upperedResponseContent
                name = responseContent.Substring(upperedResponseContent.IndexOf("<name>") + "<name>".Length, upperedResponseContent.IndexOf("</name>") - (upperedResponseContent.IndexOf("<name>") + "<name>".Length))
                name = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<name>") + "<name>".Length, _
                 upperedResponseContent.IndexOf("</name>") - (upperedResponseContent.IndexOf("<name>") + "<name>".Length) _
               )

                surname = responseContent.Substring(upperedResponseContent.IndexOf("<surname>") + "<surname>".Length, upperedResponseContent.IndexOf("</surname>") - (upperedResponseContent.IndexOf("<surname>") + "<surname>".Length))
                surname = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<surname>") + "<surname>".Length, _
                 upperedResponseContent.IndexOf("</surname>") - (upperedResponseContent.IndexOf("<surname>") + "<surname>".Length) _
               )

                gender = responseContent.Substring(upperedResponseContent.IndexOf("<gender>") + "<gender>".Length, upperedResponseContent.IndexOf("</gender>") - (upperedResponseContent.IndexOf("<gender>") + "<gender>".Length))
                gender = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<gender>") + "<gender>".Length, _
                 upperedResponseContent.IndexOf("</gender>") - (upperedResponseContent.IndexOf("<gender>") + "<gender>".Length) _
               )

                fatherName = responseContent.Substring(upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length, upperedResponseContent.IndexOf("</fatherName>") - (upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length))
                fatherName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length, _
                 upperedResponseContent.IndexOf("</fatherName>") - (upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length) _
               )

                birthPlace = responseContent.Substring(upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length, upperedResponseContent.IndexOf("</birthPlace>") - (upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length))
                birthPlace = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length, _
                  upperedResponseContent.IndexOf("</birthPlace>") - (upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length) _
                )

                birthDay = responseContent.Substring(upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length))
                birthDay = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, _
                  upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length) _
                )

                birthMonth = responseContent.Substring(upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length))
                birthMonth = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, _
                  upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length) _
                )

                birthYear = responseContent.Substring(upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length))
                birthYear = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, _
                 upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length) _
               )
                cityName = responseContent.Substring(upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length))
                cityName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, _
                 upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length) _
               )

                countyName = responseContent.Substring(upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length))
                countyName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, _
                 upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length) _
               )

                anneKizlikSoyad = responseContent.Substring(upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length, upperedResponseContent.IndexOf("</kizlikSoyad>") - (upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length))
                anneKizlikSoyad = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length, _
                 upperedResponseContent.IndexOf("</kizlikSoyad>") - (upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length) _
               )



                If resultcd <> 0 Then
                    ' name = responseContent.Substring(upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length))
                    ' name = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, _
                    '  upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length) _
                    ')
                    ' surname = responseContent.Substring(upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length) _
                    ')



                    ' gender = responseContent.Substring(upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length, upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length, _
                    '  upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length) _
                    ')

                    ' fatherName = responseContent.Substring(upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length, upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length) _
                    ')

                    ' motherName = responseContent.Substring(upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length, upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length) _
                    ')


                    ' birthDay = responseContent.Substring(upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, _
                    '  upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length) _
                    ')

                    ' birthMonth = responseContent.Substring(upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, _
                    '  upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length) _
                    ')

                    ' birthYear = responseContent.Substring(upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, _
                    '  upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length) _
                    ')
                    ' cityName = responseContent.Substring(upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, _
                    '  upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length) _
                    ')

                    ' countyName = responseContent.Substring(upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, _
                    '  upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length) _
                    ')

                    ' anneKizlikSoyad = responseContent.Substring(upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length, upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length, _
                    '  upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length) _
                    ')




                End If

                If (Not name Is Nothing) AndAlso name.Trim().ToLower() = "null" Then
                    If Not _name Is Nothing Then
                        name = _name
                    End If

                    If Not _surname Is Nothing Then
                        name = _surname
                    End If

                    resultCode = "-1"
                End If

                If resultCode <> "0" Then
                    resultCode = "-1"
                End If

                Return resultCode
            Catch ex As Exception
                Return -1
            End Try

        End Function

        Public Shared Function CheckMernisStatusFromGoverment(ByVal tcID As String, ByRef name As String, ByRef surname As String, ByRef gender As String, ByRef fatherName As String, ByRef birthDay As String, ByRef birthMonth As String, ByRef birthYear As String, ByRef cityName As String, ByRef countyName As String, ByRef anneKizlikSoyad As String, ByRef birthPlace As String) As Object

            Try

                Dim requestBody As String = String.Format("<?xml version='1.0' encoding='UTF-8'?> " & _
                                                vbNewLine & "<IWIS_IN_DATA_UNIT> " & _
                                                vbNewLine & "<IWIS_IN_HEADER version='1.0'> " & _
                                                vbNewLine & "<SYSTEM>OTONOM</SYSTEM> " & _
                                                vbNewLine & "<SERVICE>MERNIS_GET_CUSTOMER_BY_ID</SERVICE> " & _
                                                vbNewLine & "</IWIS_IN_HEADER> " & _
                                                vbNewLine & "<IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "<TYPE>1</TYPE> " & _
                                                vbNewLine & "<NATIONALID>{0}</NATIONALID> " & _
                                                 vbNewLine & " <ISLOCALRECORDVALID>false</ISLOCALRECORDVALID>" & _
                                                vbNewLine & "</IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "</IWIS_IN_DATA_UNIT>", _
                                                tcID)









                'Dim serviceAddress As String = "http://10.248.66.43:8501/WEB/IWIS"
                Dim serviceAddress As Object = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                'Dim serviceAddress As String = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                Dim data() As Byte = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("windows-1254"), System.Text.Encoding.GetEncoding("iso-8859-9"), System.Text.Encoding.GetEncoding("windows-1254").GetBytes(requestBody))
                Dim StringServiceAddress As String = Convert.ToString(serviceAddress)
                Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(serviceAddress)

                request.Method = "POST"
                request.ContentType = "content=""text/xml;charset=iso-8859-9"""
                request.ContentLength = data.Length
                Dim streamWriter As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.GetEncoding("iso-8859-9"))

                streamWriter.Write(System.Text.Encoding.GetEncoding("iso-8859-9").GetString(data))
                streamWriter.Close()


                Dim response As System.IO.Stream = request.GetResponse().GetResponseStream()
                Dim streamReader As New IO.StreamReader(response, System.Text.Encoding.GetEncoding("iso-8859-9"))
                Dim responseContent As String = streamReader.ReadToEnd()
                Dim upperedResponseContent As String = responseContent

                Dim resultCode As String = responseContent.Substring _
                ( _
                    upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length, _
                    upperedResponseContent.IndexOf("</IWIS_RETURN_CODE>") - (upperedResponseContent.IndexOf("<IWIS_RETURN_CODE>") + "<IWIS_RETURN_CODE>".Length) _
                )

                Dim _name As String = name, _surname As String = surname
                Dim resultcd As Integer = Convert.ToInt32(resultCode)
                name = upperedResponseContent
                name = responseContent.Substring(upperedResponseContent.IndexOf("<name>") + "<name>".Length, upperedResponseContent.IndexOf("</name>") - (upperedResponseContent.IndexOf("<name>") + "<name>".Length))
                name = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<name>") + "<name>".Length, _
                 upperedResponseContent.IndexOf("</name>") - (upperedResponseContent.IndexOf("<name>") + "<name>".Length) _
               )

                surname = responseContent.Substring(upperedResponseContent.IndexOf("<surname>") + "<surname>".Length, upperedResponseContent.IndexOf("</surname>") - (upperedResponseContent.IndexOf("<surname>") + "<surname>".Length))
                surname = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<surname>") + "<surname>".Length, _
                 upperedResponseContent.IndexOf("</surname>") - (upperedResponseContent.IndexOf("<surname>") + "<surname>".Length) _
               )

                gender = responseContent.Substring(upperedResponseContent.IndexOf("<gender>") + "<gender>".Length, upperedResponseContent.IndexOf("</gender>") - (upperedResponseContent.IndexOf("<gender>") + "<gender>".Length))
                gender = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<gender>") + "<gender>".Length, _
                 upperedResponseContent.IndexOf("</gender>") - (upperedResponseContent.IndexOf("<gender>") + "<gender>".Length) _
               )

                fatherName = responseContent.Substring(upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length, upperedResponseContent.IndexOf("</fatherName>") - (upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length))
                fatherName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length, _
                 upperedResponseContent.IndexOf("</fatherName>") - (upperedResponseContent.IndexOf("<fatherName>") + "<fatherName>".Length) _
               )

                birthPlace = responseContent.Substring(upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length, upperedResponseContent.IndexOf("</birthPlace>") - (upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length))
                birthPlace = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length, _
                  upperedResponseContent.IndexOf("</birthPlace>") - (upperedResponseContent.IndexOf("<birthPlace>") + "<birthPlace>".Length) _
                )

                birthDay = responseContent.Substring(upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length))
                birthDay = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, _
                  upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length) _
                )

                birthMonth = responseContent.Substring(upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length))
                birthMonth = responseContent.Substring _
                ( _
                   upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, _
                  upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length) _
                )

                birthYear = responseContent.Substring(upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length))
                birthYear = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, _
                 upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length) _
               )
                cityName = responseContent.Substring(upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length))
                cityName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, _
                 upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length) _
               )

                countyName = responseContent.Substring(upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length))
                countyName = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, _
                 upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length) _
               )

                anneKizlikSoyad = responseContent.Substring(upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length, upperedResponseContent.IndexOf("</kizlikSoyad>") - (upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length))
                anneKizlikSoyad = responseContent.Substring _
               ( _
                  upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length, _
                 upperedResponseContent.IndexOf("</kizlikSoyad>") - (upperedResponseContent.IndexOf("<kizlikSoyad>") + "<kizlikSoyad>".Length) _
               )



                If resultcd <> 0 Then
                    ' name = responseContent.Substring(upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length))
                    ' name = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length, _
                    '  upperedResponseContent.IndexOf("</NAME>") - (upperedResponseContent.IndexOf("<NAME>") + "<NAME>".Length) _
                    ')
                    ' surname = responseContent.Substring(upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</SURNAME>") - (upperedResponseContent.IndexOf("<SURNAME>") + "<SURNAME>".Length) _
                    ')



                    ' gender = responseContent.Substring(upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length, upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length, _
                    '  upperedResponseContent.IndexOf("</GENDER>") - (upperedResponseContent.IndexOf("<GENDER>") + "<GENDER>".Length) _
                    ')

                    ' fatherName = responseContent.Substring(upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length, upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</FATHERNAME>") - (upperedResponseContent.IndexOf("<FATHERNAME>") + "<FATHERNAME>".Length) _
                    ')

                    ' motherName = responseContent.Substring(upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length, upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length, _
                    '  upperedResponseContent.IndexOf("</MOTHERNAME>") - (upperedResponseContent.IndexOf("<MOTHERNAME>") + "<MOTHERNAME>".Length) _
                    ')


                    ' birthDay = responseContent.Substring(upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length, _
                    '  upperedResponseContent.IndexOf("</birthDay>") - (upperedResponseContent.IndexOf("<birthDay>") + "<birthDay>".Length) _
                    ')

                    ' birthMonth = responseContent.Substring(upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length, _
                    '  upperedResponseContent.IndexOf("</birthMonth>") - (upperedResponseContent.IndexOf("<birthMonth>") + "<birthMonth>".Length) _
                    ')

                    ' birthYear = responseContent.Substring(upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length, _
                    '  upperedResponseContent.IndexOf("</birthYear>") - (upperedResponseContent.IndexOf("<birthYear>") + "<birthYear>".Length) _
                    ')
                    ' cityName = responseContent.Substring(upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length, _
                    '  upperedResponseContent.IndexOf("</cityName>") - (upperedResponseContent.IndexOf("<cityName>") + "<cityName>".Length) _
                    ')

                    ' countyName = responseContent.Substring(upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length, _
                    '  upperedResponseContent.IndexOf("</countyName>") - (upperedResponseContent.IndexOf("<countyName>") + "<countyName>".Length) _
                    ')

                    ' anneKizlikSoyad = responseContent.Substring(upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length, upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length))
                    ' surname = responseContent.Substring _
                    '( _
                    '   upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length, _
                    '  upperedResponseContent.IndexOf("</anneKizlikSoyad>") - (upperedResponseContent.IndexOf("<anneKizlikSoyad>") + "<anneKizlikSoyad>".Length) _
                    ')




                End If

                If (Not name Is Nothing) AndAlso name.Trim().ToLower() = "null" Then
                    If Not _name Is Nothing Then
                        name = _name
                    End If

                    If Not _surname Is Nothing Then
                        name = _surname
                    End If

                    resultCode = "-1"
                End If

                If resultCode <> "0" Then
                    resultCode = "-1"
                End If

                Return resultCode
            Catch ex As Exception
                Return -1
            End Try

        End Function



        Public Shared Function CheckGreyList(ByVal tcID As String) As Object

            Try

                Dim requestBody As String = String.Format("<?xml version='1.0' encoding='UTF-8'?> " & _
                                                vbNewLine & "<IWIS_IN_DATA_UNIT> " & _
                                                vbNewLine & "<IWIS_IN_HEADER version='1.0'> " & _
                                                vbNewLine & "<SYSTEM>VAS_PORTAL</SYSTEM> " & _
                                                vbNewLine & "<SERVICE>BPM_GNL_CHECK_FRAUD</SERVICE> " & _
                                                vbNewLine & "</IWIS_IN_HEADER> " & _
                                                vbNewLine & "<IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & " <XML> " & _
                                                vbNewLine & "  <sch:FraudCheckProcessRequest xmlns:sch='avea/bpm/schemas'> " & _
                                                vbNewLine & "  <CONTRACT_TYPE>prepaid</CONTRACT_TYPE> " & _
                                                vbNewLine & " <CUSTOMER_TYPE>a</CUSTOMER_TYPE> " & _
                                                vbNewLine & " <SUB_NAME/> " & _
                                                vbNewLine & " <SUB_SURNAME/> " & _
                                                vbNewLine & "  <SUB_FATHER_NAME/> " & _
                                                vbNewLine & "   <SUB_MOTHER_SURNAME/> " & _
                                                vbNewLine & "  <SUB_BIRTHDATE/>" & _
                                                vbNewLine & " <TCKIMLIKNO>{0}</TCKIMLIKNO> " & _
                                                vbNewLine & "  <IDENTITY_TYPE/> " & _
                                                vbNewLine & "<IDENTITY_NO/> " & _
                                                vbNewLine & " <DEALER_CODE/> " & _
                                                vbNewLine & "  <COMPANY_NAME/> " & _
                                                vbNewLine & "  <COMPANY_REG_NO/>  " & _
                                                vbNewLine & "  <COMPANY_TAX_NO/> " & _
                                                vbNewLine & " <PHONE1/> " & _
                                                vbNewLine & "   <PHONE2/> " & _
                                                vbNewLine & "   <PHONE3/> " & _
                                                vbNewLine & "   <REZERV_IMSI/> " & _
                                                vbNewLine & " <REZERV_MSISDN/> " & _
                                                vbNewLine & "   <PROCESS_TYPE/> " & _
                                                vbNewLine & "  <IP/>" & _
                                                vbNewLine & "    <APPLICATION_NAME>3DSECURE</APPLICATION_NAME>" & _
                                                vbNewLine & "    <USER_ID/>" & _
                                                vbNewLine & "  <REZERV_FIELD1/> " & _
                                                vbNewLine & "  <REZERV_FIELD2/> " & _
                                                vbNewLine & "  <REZERV_FIELD3/> " & _
                                                vbNewLine & " <REZERV_FIELD4/> " & _
                                                vbNewLine & "  <CHECK_TYPE/>" & _
                                                vbNewLine & "  </sch:FraudCheckProcessRequest>" & _
                                                vbNewLine & "  </XML> " & _
                                                vbNewLine & "</IWIS_SERVICE_PARAMS> " & _
                                                vbNewLine & "</IWIS_IN_DATA_UNIT>", _
                                                tcID)



                Dim serviceAddress As Object = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
                'Dim serviceAddress As String = "http://10.4.42.42/WEB/IWIS"
                Dim data() As Byte = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("windows-1254"), System.Text.Encoding.GetEncoding("iso-8859-9"), System.Text.Encoding.GetEncoding("windows-1254").GetBytes(requestBody))
                Dim StringServiceAddress As String = Convert.ToString(serviceAddress)
                Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(serviceAddress)

                request.Method = "POST"
                request.ContentType = "content=""text/xml;charset=iso-8859-9"""
                request.ContentLength = data.Length
                Dim streamWriter As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.GetEncoding("iso-8859-9"))

                streamWriter.Write(System.Text.Encoding.GetEncoding("iso-8859-9").GetString(data))
                streamWriter.Close()


                Dim response As System.IO.Stream = request.GetResponse().GetResponseStream()
                Dim streamReader As New IO.StreamReader(response, System.Text.Encoding.GetEncoding("iso-8859-9"))
                Dim responseContent As String = streamReader.ReadToEnd()
                Dim upperedResponseContent As String = responseContent.ToUpper()

                Dim resultCode As String = responseContent.Substring _
                ( _
                    upperedResponseContent.IndexOf("<RESULT>") + "<RESULT>".Length, _
                    upperedResponseContent.IndexOf("</RESULT>") - (upperedResponseContent.IndexOf("<RESULT>") + "<RESULT>".Length) _
                )

                Dim resultcd As Integer = Convert.ToInt32(resultCode)


                Return resultCode
            Catch ex As Exception
                Return -1
            End Try

        End Function
        Public Shared Function CheckSingleIwisResult(ByVal tcID As String) As String

            Dim dt As DataTable
            Dim sub_name As String
            Dim sub_surname As String
            Dim sub_birthdate As String
            Dim submother As String
            Dim TCIDNumber As String
            Dim Identity_type As String
            Dim Identity_no As String
            Dim company_name As String
            Dim COMPANY_REG_NO As String
            Dim COMPANY_TAX_NO As String
            Dim PHONE1 As String
            Dim PHONE2 As String
            Dim fathername As String

            Dim currentculture As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("tr-TR")

            ' BSCS_6 Version (Old)
            'Dim sql As String = "	SELECT cc.ccfname      sub_name      ,	 " & _
            '            vbNewLine & "	       cc.cclname      sub_surname   ,	 " & _
            '            vbNewLine & "	       cc.ccmname      submother,	 " & _
            '            vbNewLine & "	       cu.birthdate    sub_birthdate ,	 " & _
            '            vbNewLine & "	       cu.CSTCIDNUMBER TCIDNumber    ,	 " & _
            '            vbNewLine & "	       cu.id_type      Identity_type ,	 " & _
            '            vbNewLine & "	       cu.PASSPORTNO   Identity_no   ,	 " & _
            '            vbNewLine & "	       cc.ccname       company_name  ,	 " & _
            '            vbNewLine & "	       cu.CSCOMPREGNO  COMPANY_REG_NO,	 " & _
            '            vbNewLine & "	       cu.CSCOMPTAXNO  COMPANY_TAX_NO,	 " & _
            '            vbNewLine & "	       CCTN_AREA || CCTN       PHONE1,	 " & _
            '            vbNewLine & "	       CCTN2_AREA || CCTN2       PHONE2	, " & _
            '              vbNewLine & "	       cu.csremark_1     fathername	 " & _
            '            vbNewLine & "	FROM   customer_all cu ,	 " & _
            '            vbNewLine & "	       ccontact_all cc	 " & _
            '            vbNewLine & "	WHERE  cu.customer_id=cc.customer_id	 " & _
            '            vbNewLine & "	   AND cu.custcode   =fn_msisdn_to_custcode('" & p_msisdn & "')	 "
            ' BEGIN : BSCS_IX_R3 Version (New)
            'Dim sql As String = "	SELECT cc.ccfname      sub_name      ,	 " & _
            '            vbNewLine & "	       cc.cclname      sub_surname   ,	 " & _
            '            vbNewLine & "	       cc.ccmname      submother,	 " & _
            '            vbNewLine & "	       cc.birthdate    sub_birthdate ,	 " & _
            '            vbNewLine & "	       cu.CSTCIDNUMBER TCIDNumber    ,	 " & _
            '            vbNewLine & "	       cc.id_type      Identity_type ,	 " & _
            '            vbNewLine & "	       cc.PASSPORTNO   Identity_no   ,	 " & _
            '            vbNewLine & "	       cc.ccname       company_name  ,	 " & _
            '            vbNewLine & "	       cc.CSCOMPREGNO  COMPANY_REG_NO,	 " & _
            '            vbNewLine & "	       cc.CSCOMPTAXNO  COMPANY_TAX_NO,	 " & _
            '            vbNewLine & "	       CCTN_AREA || CCTN       PHONE1,	 " & _
            '            vbNewLine & "	       CCTN2_AREA || CCTN2       PHONE2	, " & _
            '              vbNewLine & "	       cu.csremark_1     fathername	 " & _
            '            vbNewLine & "	FROM   customer_all cu ,	 " & _
            '            vbNewLine & "	       ccontact_all cc	 " & _
            '            vbNewLine & "	WHERE  cu.customer_id=cc.customer_id	 " & _
            '            vbNewLine & "	   AND cu.custcode   =fn_msisdn_to_custcode('" & p_msisdn & "')	 "
            '' END : BSCS_IX_R3 Version (New)

            'dt = persistent.myDBConn.myORATable(sql)




            ' Kayıt geliyorsa... 
            'If dt.Rows.Count > 0 Then

            '    sub_name = Nvl(dt.Rows(0)(0), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    sub_surname = Nvl(dt.Rows(0)(1), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    submother = Nvl(dt.Rows(0)(2), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    sub_birthdate = Nvl(dt.Rows(0)(3), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    TCIDNumber = Nvl(dt.Rows(0)(4), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    Identity_type = Nvl(dt.Rows(0)(5), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    Identity_no = Nvl(dt.Rows(0)(6), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    company_name = Nvl(dt.Rows(0)(7), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    COMPANY_REG_NO = Nvl(dt.Rows(0)(8), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    COMPANY_TAX_NO = Nvl(dt.Rows(0)(9), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    PHONE1 = Nvl(dt.Rows(0)(10), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    PHONE2 = Nvl(dt.Rows(0)(11), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")
            '    fathername = Nvl(dt.Rows(0)(12), "").Replace("&", "&amp;").Replace("'", "&apos;").Replace("""", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;")



            Dim IwisString As String = "<?xml version='1.0' encoding='ISO-8859-9'?>	" & _
                            vbNewLine & "	<IWIS_IN_DATA_UNIT>	" & _
                            vbNewLine & "      <IWIS_IN_HEADER version='1.0'>	" & _
                            vbNewLine & "             <SYSTEM>BILLINGNET</SYSTEM>	" & _
                            vbNewLine & "             <SERVICE>BPM_GNL_CHECK_FRAUD</SERVICE>	" & _
                            vbNewLine & "      </IWIS_IN_HEADER>	" & _
                            vbNewLine & "      <IWIS_SERVICE_PARAMS>	" & _
                             vbNewLine & "      <XML><sch:FraudCheckProcessRequest xmlns:sch=""avea/bpm/schemas"">	" & _
                            vbNewLine & "	<CONTRACT_TYPE>postpaid</CONTRACT_TYPE>	" & _
                            vbNewLine & "	<CUSTOMER_TYPE>a</CUSTOMER_TYPE>	" & _
                            vbNewLine & "	<SUB_NAME></SUB_NAME>	" & _
                            vbNewLine & "	<SUB_SURNAME></SUB_SURNAME>	" & _
                            vbNewLine & "	<SUB_FATHER_NAME></SUB_FATHER_NAME>	" & _
                            vbNewLine & "	<SUB_MOTHER_SURNAME></SUB_MOTHER_SURNAME>	" & _
                            vbNewLine & "	<SUB_BIRTHDATE></SUB_BIRTHDATE>	" & _
                            vbNewLine & "	<TCKIMLIKNO>" & tcID & "</TCKIMLIKNO>	" & _
                            vbNewLine & "	<IDENTITY_TYPE></IDENTITY_TYPE>	" & _
                            vbNewLine & "	<IDENTITY_NO></IDENTITY_NO>	" & _
                            vbNewLine & "	<DEALER_CODE></DEALER_CODE>	" & _
                            vbNewLine & "	<COMPANY_NAME></COMPANY_NAME>	" & _
                            vbNewLine & "	<COMPANY_REG_NO></COMPANY_REG_NO> " & _
                            vbNewLine & "	<COMPANY_TAX_NO></COMPANY_TAX_NO>	" & _
                            vbNewLine & "	<PHONE1></PHONE1>	" & _
                            vbNewLine & "	<PHONE2></PHONE2>	" & _
                            vbNewLine & "	<PHONE3></PHONE3>	" & _
                            vbNewLine & "	<REZERV_IMSI></REZERV_IMSI>	" & _
                            vbNewLine & "	<REZERV_MSISDN></REZERV_MSISDN>	" & _
                            vbNewLine & "	<PROCESS_TYPE></PROCESS_TYPE>	" & _
                            vbNewLine & "	<IP></IP>	" & _
                            vbNewLine & "	<APPLICATION_NAME>REACTIVATION_TOOL</APPLICATION_NAME>	" & _
                            vbNewLine & "	<USER_ID>" & System.Web.HttpContext.Current.Session("user").ToString() & "</USER_ID>	" & _
                            vbNewLine & "	<REZERV_FIELD1></REZERV_FIELD1>	" & _
                            vbNewLine & "	<REZERV_FIELD2></REZERV_FIELD2>	" & _
                            vbNewLine & "	<REZERV_FIELD3></REZERV_FIELD3>	" & _
                            vbNewLine & "	<REZERV_FIELD4></REZERV_FIELD4>	" & _
                             vbNewLine & "	<CHECK_TYPE>2</CHECK_TYPE>	" & _
                            vbNewLine & "      </sch:FraudCheckProcessRequest></XML>	" & _
                              vbNewLine & "      </IWIS_SERVICE_PARAMS>	" & _
                            vbNewLine & "	</IWIS_IN_DATA_UNIT>	"

            'REACTIVATION_TOOL

            'Test 10.4.54.24
            'Prod 10.4.107.21
            ' BErk Test http://10.4.42.42/WEB/IWIS
            Dim ip As String = persistent.myDBConn.ORAScalar("select path from BILLINTRA.BILLINGNET_IWIS_CALL_IP_CONFIG")
            Dim data() As Byte = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding("windows-1254"), System.Text.Encoding.GetEncoding("iso-8859-9"), System.Text.Encoding.GetEncoding("windows-1254").GetBytes(IwisString))
            'Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://10.4.42.42/WEB/IWIS")
            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(ip)
            request.Method = "POST"
            request.ContentType = "content=""text/xml;charset=iso-8859-9"""
            request.ContentLength = data.Length
            Dim streamWriter As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.GetEncoding("iso-8859-9"))

            streamWriter.Write(System.Text.Encoding.GetEncoding("iso-8859-9").GetString(data))
            streamWriter.Close()


            Dim response As System.IO.Stream = request.GetResponse().GetResponseStream()
            Dim str As New IO.StreamReader(response)
            Dim xml As String = str.ReadToEnd()
            Dim sonuc As Integer = xml.IndexOf("<RESULT>")
            Dim last As Integer = xml.IndexOf("</RESULT>") - (sonuc + 8)

            Dim sql2 As String = "insert into BILLINTRA.IWIS_LOG values (" & Globals.TruncateDbText(IwisString) & " ," & Globals.TruncateDbText(xml) & ",'SingleReactivation',sysdate,'" & System.Web.HttpContext.Current.Session("user") & "')"
            persistent.myDBConn.ORAExecute(sql2)

            If sonuc <> -1 Then
                If xml.Substring(sonuc + 8, 1) = 0 And last = 1 Then
                    Return "OK"
                ElseIf xml.Substring(sonuc + 8, 1) = 1 And last = 1 Then
                    Return "MSISDN BLACKLIST. "
                ElseIf xml.Substring(sonuc + 8, 2) = 11 And last = 2 Then


                    Dim sr As New System.IO.StringReader(xml)
                    Dim XmlDoc As XmlDocument = New XmlDocument
                    XmlDoc.Load(sr)
                    'or just in this case doc.LoadXML(xmlString)
                    Dim msisdn As String
                    Dim amount As String
                    Dim info As String
                    Dim allMessage As String = "MSISDN GRAYLIST." & "<br>"
                    Dim reader As New XmlNodeReader(XmlDoc)
                    While reader.Read()
                        Select Case reader.NodeType
                            Case XmlNodeType.Element

                                If reader.Name = "MSISDN" Then
                                    msisdn = reader.ReadString
                                    allMessage += " MSISDN:" & msisdn
                                End If
                                If reader.Name = "AMOUNT" Then
                                    amount = reader.ReadString
                                    allMessage += "  AMOUNT:" & amount & "<br>"
                                End If
                                If reader.Name = "INFO" Then
                                    info = reader.ReadString
                                    allMessage += " INFO:" & info & "<br>"
                                End If
                        End Select

                    End While
                    Return allMessage
                Else
                    Return xml.Substring(sonuc, last)
                End If
            Else
                Return "IWIS BPM_GNL_CHECK_FRAUD Servisinde hata oluştu."
            End If
            'Else
            'Return "İlgili Custcode için kayıt bulunamadı:"
            'End If
            System.Threading.Thread.CurrentThread.CurrentCulture = currentculture
        End Function

        Public Shared Function GetCustDealerInfoWithCOID(ByVal pin_COID As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustDealerInfoFromCOID")
            command.Parameters.Add("pin_CO_ID", OracleType.Int32).Value = pin_COID
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            ''LOGLAMA
            Dim asd As String = Convert.ToString(pin_COID)
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New CustomerDetails2()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", asd, "null", "Select(GetCustDealerInfoWithCOID)", "ChangeSim", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function
        Public Shared Function GetCustDealerInfoWithMSISDN(ByVal pin_MSISDN As String) As DataTable
            pin_MSISDN = "90" + pin_MSISDN
            Dim command As New OracleCommand(dbPackageName & "GetCustDealerInfoFromMSISDN")
            command.Parameters.Add("pin_MSISDN", OracleType.VarChar).Value = pin_MSISDN
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            ''LOGLAMA.Substring(0, 10)
            Dim MSISDN_log As String = pin_MSISDN.Substring(2, 10)
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New CustomerDetails2()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", "null", MSISDN_log, "Select(GetCustDealerInfoWithMSISDN)", "ChangeSim", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function

        Public Shared Function DisplaySimHistory(ByVal pin_CO_ID As Integer, ByVal pin_userid As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "DisplaySimHistory")
            command.Parameters.Add("pin_CO_ID", OracleType.Int32).Value = pin_CO_ID
            command.Parameters.Add("pin_userid", OracleType.VarChar).Value = pin_userid
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            ''LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New CustomerDetails2()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", pin_CO_ID, "null", "Select(GetCustDealerInfoWithCOID)", "ChangeSim", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function

        Public Shared Function GetSIMChangeReason() As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetSIMChangeReason")
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function ChangeSIMCard(ByVal pin_res_type As Integer, ByVal pin_old_res_num As String, ByVal pin_res_id As Integer, ByVal pin_hlcode As Integer, ByVal pin_smc_id As Integer, ByVal pin_reason As Integer, ByVal pin_retention As Integer, ByVal pin_co_id As Integer, ByVal pin_new_dealer_custcode As String, ByVal pin_userid As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "ChangeSIMCard")
            command.Parameters.Add("pin_res_type", OracleType.Int32).Value = pin_res_type
            command.Parameters.Add("pin_old_res_num", OracleType.VarChar).Value = pin_old_res_num
            command.Parameters.Add("pin_res_id", OracleType.Int32).Value = pin_res_id
            command.Parameters.Add("pin_hlcode", OracleType.Int32).Value = pin_hlcode
            command.Parameters.Add("pin_smc_id", OracleType.Int32).Value = pin_smc_id
            command.Parameters.Add("pin_reason", OracleType.Int32).Value = pin_reason
            command.Parameters.Add("pin_retention", OracleType.Int32).Value = pin_retention
            command.Parameters.Add("pin_co_id", OracleType.Int32).Value = pin_co_id
            command.Parameters.Add("pin_new_dealer_custcode", OracleType.VarChar).Value = pin_new_dealer_custcode
            command.Parameters.Add("pin_userid", OracleType.VarChar).Value = pin_userid
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            ''LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New CustomerDetails2()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", pin_co_id, "null", "Select(ChangeSIMCard)", "ChangeSim", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function

        Public Shared Function GetDealeridFromCustomerid(ByVal pin_customer_id As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetDealeridFromCustomerid")
            command.Parameters.Add("pin_customer_id", OracleType.Int32).Value = pin_customer_id
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output

            Return ExecuteDataTable(command)

        End Function
        'procedure UserInfo (pin_userid IN varchar2,p_cursor OUT r_cursor_type)
        Public Shared Function UserInfo(ByVal pin_userid As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "UserInfo")
            command.Parameters.Add("pin_userid", OracleType.VarChar).Value = pin_userid
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output

            Return ExecuteDataTable(command)

        End Function

        Public Shared Function GetResIdForNewSim(ByVal pin_new_res_num As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetResIdForNewSim")
            command.Parameters.Add("pin_new_res_num", OracleType.VarChar).Value = pin_new_res_num
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function


        Public Shared Function DealerControl(ByVal pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "DealerControl")
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function


        Public Shared Function ExecuteNonQuery(ByVal command As OracleCommand, ByRef MESSAGE As String)
            Dim connection As New OracleConnection(ConnStr)
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure

            Try
                connection.Open()
                command.ExecuteNonQuery()
            Catch ex As Exception
                MESSAGE = ex.Message.ToString
            Finally
                connection.Close()
            End Try
        End Function
        Public Shared Function ExecuteDataTable(ByVal command As OracleCommand, Optional ByVal directSql As Boolean = 0) As DataTable
            Dim connection As New OracleConnection(ConnStr)
            Dim dataAdapter As New OracleDataAdapter(command)
            Dim dataTable As New DataTable
            Dim dataSet As New DataSet

            command.Connection = connection

            If Not (directSql) Then
                command.CommandType = CommandType.StoredProcedure
            End If

            Try
                connection.Open()
                dataAdapter.Fill(dataSet)
                dataTable = dataSet.Tables(0)
            Catch ex As Exception
            Finally
                connection.Close()
                dataSet.Dispose()
            End Try

            Return dataTable
        End Function




    End Class
End Namespace


